const path = require("path");
const webpack = require("webpack");

module.exports = {
    devtool: 'source-map',
    entry: {
        'card01': './src/components/card01/index.js',
        'card02': './src/components/card02/index.js',
        'zhtt-npm-mult': './src/index.js'
    },
    output: {
        path: path.resolve(__dirname, './zhtt-npm-mult/lib'),
        filename: '[name].js',
        libraryTarget: 'umd',
        library: '[name]',
        libraryExport: 'default'
    },
    module: {
        rules: [
            {
                test: /\.vue$/,
                loader: 'vue-loader'
            },
            {
                test: /\.css$/,
                use: [
                    { loader: "style-loader" },
                    { loader: "css-loader" },
                    { loader: "less-loader" },
                    { loader: "postcss-loader" }
                ]
            },
            {
                test: /\.s[ac]ss$/,
                use: [
                    { loader: "style-loader" },
                    { loader: "css-loader" },
                    { loader: "less-loader" },
                    { loader: "postcss-loader" }
                ]
            },
            {
                test: /\.less$/,
                use: [
                    { loader: "style-loader" },
                    { loader: "css-loader" },
                    { loader: "less-loader" }
                ]
            },
            {
                test: /\.js$/,
                exclude: /node_modules|vue\/dist|vue-router\/|vue-loader\/|vue-hot-reload-api\//,
                loader: 'babel-loader'
            },
            {
                test: /\.(png|jpg|gif|ttf|svg|woff|eot)$/,
                loader: 'url-loader',
                query: {
                    limit: 30000,
                    name: '[name].[ext]?[hash]'
                }
            }
        ]
    },
    plugins: [
        new webpack.DefinePlugin({
            "process.env": {
                NODE_ENV: JSON.stringify("production")
            }
        })
    ]
};